﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.Servidor1;

namespace WebApplication1
{
    public partial class VerInventarios : System.Web.UI.Page
    {
        Service1 servidor;
        protected void Page_Load(object sender, EventArgs e)
        {
            servidor = (Service1)Session["Server"];
            if (servidor != null)
            {
                List<string> articulos = servidor.ConsultarEmpresa(4, Session["NombreEmpresaUsuario"].ToString()).ToList();
                DropDownList1.DataSource = articulos;
                DropDownList1.DataBind();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string empresa = Session["NombreEmpresaUsuario"].ToString();
            List<string> articuloInfo = servidor.Obtener_Articulos(true, DropDownList1.SelectedValue.ToString(), empresa).ToList();
            for (int i = 0; i < articuloInfo.Count(); i++)
            {
                articuloInfo[i] = articuloInfo[i].Split(';')[10] + "\t" + articuloInfo[i].Split(';')[12] +
                    "\t" + articuloInfo[i].Split(';')[13] + "\t" + articuloInfo[i].Split(';')[14] +
                    "\t" + articuloInfo[i].Split(';')[15] + "\t" + articuloInfo[i].Split(';')[16];
            }
            ListBox1.DataSource = articuloInfo;
            ListBox1.DataBind();
        }
    }
}